Neo4j
Querying Overview
Qarbine interacts with Neo4j using the Cypher querying language enabling access to Neo4j’s diverse graph database features. There are querying tutorials available and a good starting point is the page at https://neo4j.com/docs/getting-started/appendix/tutorials/tutorials-overview/.
There are several guided tours and data sets with a couple using movies as the theme at
https://neo4j.com/docs/getting-started/appendix/example-data/
When you sign on to your Neo4j cloud database there are several very useful resources available as shown below.
The Neo4j Bloom tool is also useful for understanding graph data.
There are many examples in Neo4j components in the catalog folder with the path shown below.
Prerequisites
Prior to using Qarbine’s embeddings(...) macro function or the SQL-like query function nearText(...), the Qarbine Administrator must first configure “AI Assistant(s)”. The AI Assistants provide access to various popular Generative AI services and are referenced using an alias. Check with your Qarbine administrator for which ones are available and their proper use. For example, when using dynamic query vector embeddings, the model used by the AI Assistant must be compatible with the one used to generate the original embedding values in the database.
Query Specification
The primary query specification syntax is Cypher. There are a few exceptions noted in the section below regarding Qarbine virtual queries. Cypher is Neo4j’s declarative and GQL conformant query language. It provides a visual way of matching patterns and relationships by having its own design based on ASCII-art type of syntax:
(:nodes)-[:ARE_CONNECTED_TO]->(:otherNodes)
Round brackets are used to represent (:Nodes), and -[:ARROWS]→ to represent a relationship between the (:Nodes). With this query syntax, you can perform read operations on your graph.
Some of the material below is a subset from https://neo4j.com/docs/getting-started/cypher/
A graph database consists mainly of nodes and relationships. Nodes are often used to represent nouns or objects in your data model. In Cypher, you can depict a node by surrounding it with parentheses, e.g. (node).
In Cypher, relationships are represented as square brackets and an arrow connecting two nodes (e.g. (Node1)-[ ]→(Node2)). Relationships always have a direction which is indicated by an arrow.
They can go from left to right:
(p:Person)-[:LIKES]->(t:Technology)
From right to left:
(p:Person)<-[:LIKES]-(t:Technology)
Or be undirected (where the direction is not specified):
MATCH (p:Person)-[:LIKES]-(t:Technology)
Some Qarbine examples make use of Cypher variables which are different from Qarbine variables in this context. They are similar to SQL aliases in usage. Here is a query without a variable
MATCH (:Person)
RETURN Person
Here is one using a variable
MATCH (p:Person)
RETURN p
Troubleshooting
If the query run in Qarbine is returning error or unexpected results then it is advised to use the native Neo4j tools. You can sign on at https://browser.neo4j.io and then navigate to the query tools.
From there copy and paste or otherwise to determine the behavior of your query. Once satisfied, make the adjustment back in the Qarbine world.
Qarbine Virtual Queries
As noted above, the primary query specification syntax is Cypher. There are a few exceptions to interacting with the database which are mainly DBA oriented. These queries are recognized by the Qarbine Neo4j driver and perform common database retrievals.
Query | Description |
---|---|
list databases | Return a list of databases and their current status. |
list labels | Return a list of Neo4j labels. |
describe labels | Provide details on all of the labels. This may take a while depending on your database structure. |
describe label LABEL | Provide details on the given label. |
See the “DBA Productivity” section of the online documentation for more details.